Add per-source telemetry for package IDs containing non-ASCII characters#7213
Open
Add per-source telemetry for package IDs containing non-ASCII characters#7213
Conversation
Copilot
AI
changed the title
[WIP] Add telemetry for non-standard package ID tracking
Add per-source telemetry for non-standard package ID characters
Mar 13, 2026
jeffkl
reviewed
Mar 16, 2026
src/NuGet.Clients/NuGet.VisualStudio.Common/Telemetry/PackageSourceTelemetry.cs
Outdated
Show resolved
Hide resolved
jeffkl
reviewed
Mar 16, 2026
src/NuGet.Clients/NuGet.VisualStudio.Common/Telemetry/PackageSourceTelemetry.cs
Outdated
Show resolved
Hide resolved
… per feed source Co-authored-by: jeffkl <17556515+jeffkl@users.noreply.github.com>
Co-authored-by: jeffkl <17556515+jeffkl@users.noreply.github.com>
Co-authored-by: jeffkl <17556515+jeffkl@users.noreply.github.com>
7e34992 to
79664c2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
Fixes: NuGet/Home#14212
Description
Adds telemetry to track whether any package ID contains characters outside
[A-Za-z0-9.\-](i.e., anything other than ASCII letters, digits,., or-). This is emitted in two places:PackageSourceDiagnosticsevent) — correlates non-standard ID usage to specific feed providersProjectRestoreInformationevent) — indicates whether any resolved package in the restore graph has a non-standard IDProtocol layer
PackageIdproperty toProtocolDiagnosticNupkgCopiedEvent(nullable; new 3-param constructor, old 2-param delegates to it)FindPackagesByIdNupkgDownloader→identity.IdLocalPackageArchiveDownloader→_packageIdentity.IdLocalV3FindPackageByIdResource/LocalV2FindPackageByIdResource→idparameterPublicAPI.Unshipped.txtfilesPer-source telemetry (
PackageSourceTelemetry)Dataclass: newIdContainsNonAsciiCharacterbool, sticky-true once any non-standard ID is seen for that sourceReadOnlySpan<char>character loop (local functionHasNonASCIICharacters)AddNupkgCopiedData: skips check whenPackageIdis null (events raised by old constructor)ToTelemetryAsync: emitsnupkgs.idcontainsnonasciicharacteralongside the existingnupkgs.copied/nupkgs.bytesPer-restore telemetry (
RestoreCommand)AnyPackageIdContainsNonASCIICharactersproperty on theProjectRestoreInformationtelemetry eventTests
PackageSourceTelemetryTests— Existing tests coveringAddNupkgCopiedDatafor: all-standard IDs →false; non-standard IDs (underscore, Unicode, space,@,+) →true; mixed batch with one non-standard → stickytrue; nullPackageId→false.ToTelemetry_WithData_CreatesTelemetryPropertiesasserts the new property is emitted.RestoreCommandTests— New tests:ExecuteAsync_WithASCIIPackageId_AnyPackageIdContainsNonASCIICharactersIsFalse— standard[A-Za-z0-9.-]package →falseExecuteAsync_WithNonASCIIPackageId_AnyPackageIdContainsNonASCIICharactersIsTrue—[Theory]with underscore, Kelvin sign (U+212A), Greek alpha (U+03B1), accented Latin (U+00E9), Cyrillic (U+0410) →trueExecuteAsync_WithMixedPackageIds_AnyPackageIdContainsNonASCIICharactersIsTrue—[Theory]where direct dep is standard but transitive dep has non-standard chars →truePR Checklist